package com.dev.swagger.config;

import com.dev.swagger.util.IpUtils;
import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import org.springdoc.core.GroupedOpenApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;


/**
 * @ClassName : SwaggerConfig  //类名
 * @Description : swagger配置  //描述
 * @Date: 2020-11-18 11:56  //时间
 */
@Configuration
//@ComponentScan(basePackages = "com.dev.swagger.controller")
public class SwaggerConfig {
    @Bean
    public GroupedOpenApi adminApi() {
        return GroupedOpenApi.builder()
                .group("后台接口")
                .pathsToMatch("/**")
                .packagesToScan("com.dev.swagger")
                .build();
    }

    @Bean
    public OpenAPI springShopOpenAPI() {
        return new OpenAPI()
                .info(new Info()
                        .title("knife4j测试项目-接口文档")
                        .description("测试：***文档***")
                        .version("v1.0")
                        .contact(new Contact().name("admin").url(IpUtils.getHostIp()))
                        .license(new License().name("admin").url(IpUtils.getHostIp())))
                        .externalDocs(new ExternalDocumentation()
                            .description("null")
                            .url("null")
                        );
    }

}
